--- a/src/dtls.c
+++ b/src/dtls.c
@@ -698,8 +698,10 @@ dtls dtls_create(uint16_t port)
   if (!_ssl_initialized)
     {
       _ssl_initialized = true;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
       SSL_load_error_strings();
       SSL_library_init();
+#endif
     }
   if (!d)
     goto fail;
@@ -711,9 +713,9 @@ dtls dtls_create(uint16_t port)
     goto fail;
 
 #ifdef USE_ONE_CONTEXT
-  SSL_CTX *ctx = SSL_CTX_new(DTLSv1_method());
+  SSL_CTX *ctx = SSL_CTX_new(DTLS_method());
 #else
-  SSL_CTX *ctx = SSL_CTX_new(DTLSv1_server_method());
+  SSL_CTX *ctx = SSL_CTX_new(DTLS_server_method());
 #endif /* USE_ONE_CONTEXT */
   if (!ctx)
     {
@@ -1002,6 +1004,7 @@ _client_psk(SSL *ssl,
 
 bool dtls_set_psk(dtls d, const char *psk, size_t psk_len)
 {
+#ifndef OPENSSL_NO_PSK
   free(d->psk);
   d->psk = malloc(psk_len);
   if (!d->psk)
@@ -1011,6 +1014,9 @@ bool dtls_set_psk(dtls d, const char *ps
   SSL_CTX_set_psk_client_callback(d->ssl_client_ctx, _client_psk);
   SSL_CTX_set_psk_server_callback(d->ssl_server_ctx, _server_psk);
   return true;
+#else
+  return false;
+#endif
 }
 
 bool dtls_cert_to_pem_buf(dtls_cert cert, char *buf, int buf_len)
